﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using MadMediaManager.Core.Interfaces.Domain;

namespace MadMediaManager.Core.Interfaces.DataAccess.Repositories
{
    public interface ILinqEnabledRepository<T, in TId> : IRepository<T, TId> where T : IEntity<TId>
    {
        /// <summary>
        /// Get a single <typeparamref name="T"/> based on an expression
        /// </summary>
        /// <param name="expression">The expression</param>
        /// <returns></returns>
        T Get(Expression<Func<T, bool>> expression);

        /// <summary>
        /// Gets all records from the database meeting the requirements of the expression.
        /// </summary>
        /// <param name="expression">The expression used to evaluate.</param>
        /// <returns></returns>
        IEnumerable<T> GetAll(Expression<Func<T, bool>> expression);

        /// <summary>
        /// Returns a generic queryable link to the database with which Linq expressions can be used.
        /// Implementations of this method may be incomplete depending on the Linq provider.
        /// </summary>
        /// <returns></returns>
        IQueryable<T> Query();
    }
}
